Hi @Nishchitagaddam, you can find an incident with a given incident key using this endpoint:
https://api-reference.pagerduty.com/#!/Incidents/get_incidents
Here is a sample curl request:
curl -X GET --header 'Accept: application/vnd.pagerduty+json;version=2' --header 'Authorization: Token token=xxxxxxxxxxxxxxxx' 'https://api.pagerduty.com/incidents?incident_key=sample_key&time_zone=UTC'
Note that if you have alerts enabled, using this filter will still work, as it will search the alert key instead of the incident key.
If there is an incident with this incident/alert key, you should see a response that looks something like this:
{
"incidents": [
{
"incident_number": 834,
...
"id": "P8325WZ",
...
}
],
"limit": 25,
"offset": 0,
"total": null,
"more": false
}
You can use the incident ID in the response (in this case P8325WZ
) to update this incident using the Manage incidents endpoint. Here is a sample curl request to acknowledge an incident:
curl -X PUT --header 'Content-Type: application/json' --header 'Accept: application/vnd.pagerduty+json;version=2' --header 'From: example@email.invalid' --header 'Authorization: Token token=xxxxxxxxxxxxxxxx' -d '{
"incidents": [
{
"id": "P8325WZ",
"type": "incident_reference",
"status": "acknowledged"
}
]
}' 'https://api.pagerduty.com/incidents'
Note that this endpoint requires a login email of a user on the account to be passed into the request headers. You can also use the PUT Incidents endpoint to accomplish this; the manage incidents endpoint has the advantage of being able to update multiple incidents at once.
I hope that helps!